Skip to content

fix(@angular/build): ensure @angular/compiler is loaded for Vitest TestBed initialization - #34202

Merged
clydin merged 1 commit into
angular:mainfrom
clydin:fix/vitest-compiler-init
Sep 30, 2026
Merged

clydin merged 1 commit into
angular:mainfrom
clydin:fix/vitest-compiler-init

Conversation

@clydin

@clydin clydin commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Provide a dedicated setup file to import '@angular/compiler' prior to TestBed initialization. This ensures the compiler facade is published before 'init-testbed.js' or any shared code-split chunks (such as those configured via 'providersFile') are evaluated, avoiding JIT compilation errors when injectable dependencies are resolved during test initialization.

Closes #31993

@clydin clydin added the target: patch This PR is targeted for the next patch release label Sep 29, 2026
@clydin
clydin force-pushed the fix/vitest-compiler-init branch from ff9ce8c to 31b4ad1 Compare September 29, 2026 16:49
@clydin
clydin marked this pull request as ready for review September 29, 2026 17:10

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds an initialization step for the Angular compiler (@angular/compiler) in the Vitest unit test runner by registering a new virtual file and entry point (init-compiler.js) that imports @angular/compiler and prepends it to the Vitest setup files. Additionally, a new integration test has been added to verify that providers injecting services requiring JIT compilation function correctly. No review comments were provided, so there is no feedback to address.

@clydin clydin added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 29, 2026
@clydin
clydin requested a review from alan-agius4 September 29, 2026 17:18
…stBed initialization

Provide a dedicated setup file to import '@angular/compiler' prior to TestBed initialization. This ensures the compiler facade is published before 'init-testbed.js' or any shared code-split chunks (such as those configured via 'providersFile') are evaluated, avoiding JIT compilation errors when injectable dependencies are resolved during test initialization.
@clydin
clydin force-pushed the fix/vitest-compiler-init branch from 31b4ad1 to 6aa8648 Compare September 29, 2026 18:05
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 30, 2026
@clydin
clydin merged commit ce57763 into angular:main Sep 30, 2026
40 checks passed
@clydin

clydin commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the fix/vitest-compiler-init branch September 30, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@angular/build:unit-test with Vitest test runner throws Failed to import test file error

2 participants